#!/bin/bash
#SBATCH --gpus=4
#SBATCH -x paraai-n32-h-01-agent-[1-33],paraai-n32-h-01-agent-[48-56],paraai-n32-h-01-agent-[63-197]
export PYTHONUNBUFFERED=1

model=qwen1.8b.chat
new_date=$(date +%Y-%m-%d)_${model}
if [ ! -d "log/$new_date" ]; then
    mkdir -p "log/$new_date"
fi

model_name=Qwen-1_8B-Chat
data_type=CKnowEdit
data_path=../../EasyEdit/dataset/ccks2024_know_edit/ccks-CKnowEdit.json

# module load compilers/cuda/12.1
# module load cudnn/8.8.1.3_cuda12.x
# module load compilers/gcc/11.3.0
# source activate ke2torch23cu121
# export HUGGINGFACE_CACHE=/home/bingxing2/home/scx7avs/lyc/huggingface/
# source activate torch23py310
export HUGGINGFACE_CACHE=/root/huggingface/

batch_size=20
ff_attrs=mlp.w1
prob_type=target_new
start_idx=423
end_idx=700


idx1=$(($i * $skip))
idx2=$(($i * $skip + $skip))
layer_idx=$idx1,$idx2
echo "$i-$model-$data_type-$layer_idx-$start_idx-$end_idx-bs$batch_size-$prob_type-$ff_attrs"
CUDA_VISIBLE_DEVICES=$i python kn.py \
    --model_name $model_name \
    --start_idx $start_idx \
    --end_idx  $end_idx \
    --batch_size $batch_size \
    --data_type $data_type \
    --data_path $data_path \
    --transformer_layers_attr transformer.h \
    --ff_attrs $ff_attrs \
    --prob_type $prob_type \
    --layer_idx $layer_idx \
    --steps 20 \
    > log/$new_date/$i-$model-$data_type-$layer_idx-$start_idx-$end_idx-bs$batch_size-$prob_type-$ff_attrs-7.log 2>&1 &

# skip=3
# for i in $(seq 0 7); do
#     idx1=$(($i * $skip))
#     idx2=$(($i * $skip + $skip))
#     layer_idx=$idx1,$idx2
#     echo "$i-$model-$data_type-$layer_idx-$start_idx-$end_idx-bs$batch_size-$prob_type-$ff_attrs"
#     CUDA_VISIBLE_DEVICES=$i python kn.py \
#         --model_name $model_name \
#         --start_idx $start_idx \
#         --end_idx  $end_idx \
#         --batch_size $batch_size \
#         --data_type $data_type \
#         --data_path $data_path \
#         --transformer_layers_attr transformer.h \
#         --ff_attrs $ff_attrs \
#         --prob_type $prob_type \
#         --layer_idx $layer_idx \
#         --steps 20 \
#         > log/$new_date/$i-$model-$data_type-$layer_idx-$start_idx-$end_idx-bs$batch_size-$prob_type-$ff_attrs-7.log 2>&1 &
# done


# i=2
# for ff_attrs in {mlp.w1,mlp.w2,attn.c_attn,attn.c_proj}; do
#     echo "$i $model_name $data_type $batch_size $prob_type $ff_attrs $layer_idx"
#     start_idx=423
#     end_idx=700 # 700-277
#     CUDA_VISIBLE_DEVICES=$i python kn.py \
#         --model_name $model_name \
#         --start_idx $start_idx \
#         --end_idx  $end_idx \
#         --batch_size $batch_size \
#         --data_type $data_type \
#         --data_path $data_path \
#         --transformer_layers_attr transformer.h \
#         --ff_attrs $ff_attrs \
#         --prob_type $prob_type \
#         --layer_idx $layer_idx \
#         --steps $batch_size \
#         --next_token answer_next_token \
#         > log/$new_date/$i-$model-$data_type-$layer_idx-$start_idx-$end_idx-bs$batch_size-$prob_type-$ff_attrs-1.log 2>&1 &
#     wait
# done


# for ff_attrs in {mlp.w1,mlp.w2,attn.c_attn,attn.c_proj}; do
#     echo "$i $model_name $data_type $batch_size $prob_type $ff_attrs $layer_idx $start_idx $end_idx"
#     CUDA_VISIBLE_DEVICES=$i python kn.py \
#         --model_name $model_name \
#         --start_idx $start_idx \
#         --end_idx  $end_idx \
#         --batch_size $batch_size \
#         --data_type $data_type \
#         --data_path $data_path \
#         --transformer_layers_attr transformer.h \
#         --ff_attrs $ff_attrs \
#         --prob_type $prob_type \
#         --layer_idx $layer_idx \
#         --steps $batch_size \
#         --next_token answer_next_token \
#         > log/$new_date/$i-$model-$data_type-$layer_idx-$start_idx-$end_idx-bs$batch_size-$prob_type-$ff_attrs-1.log 2>&1 &
#     wait
# done
